<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<%
//设置请求编码格式
request.setCharacterEncoding("utf-8");
//获取请求对象的请求参数
String user="huangbiao";
if(!"".equals(request.getParameter("user"))){
	user=java.net.URLEncoder.encode(request.getParameter("user"),"utf-8");
}
//创建cookie对象
Cookie cookie=new Cookie("myCookie",user+"#"+"aaa");
//设置cookie存活时间
cookie.setMaxAge(5);
//将cokie对象添加进HTTP请求头里面
response.addCookie(cookie);
 
%>

<script type="text/javascript">
//当前页面打开指定url
window.location.href="readCookie.jsp"

</script>













</body>
</html>